import { useSelector } from "react-redux";
import { useState, useEffect } from "react";
function Result() {
    let { answersId, standAnswer } = useSelector((state: any) => state.questionare)
    console.log(answersId);
    console.log(standAnswer)
    let trueNum = 0;
    const [scope, setScope] = useState<any>(0)
    for (let i = 0; i < standAnswer.length; i++) {
        if (answersId[i] == standAnswer[i]) {
            trueNum++;
        }
    }
    let result = trueNum / standAnswer.length * 100;
    console.log(result);

    useEffect(() => {
        setScope(result)
    })
    return (
        <div>
            <h1>问卷结果</h1>
            <div className="result">
                <p>感谢您的参与！以下是您的问卷结果：{scope}分</p>
            </div>
        </div>
    ) // 这里可以添加问卷结果的显示逻辑，比如显示用户的回答和得分等信息。
}
export default Result;